<!--
 * @Descripttion:
 * @version:
 * @Author: tanghao1
 * @Date: 2021-03-11 15:39:10
 * @LastEditors: tanghao1
 * @LastEditTime: 2021-03-19 17:05:17
-->
<template>
  <el-dialog
    ref="refFather"
    :title="'选择父级联动'"
    :visible.sync="dialogShow"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :hide-func-bar="true"
    :before-close="clearForm"
    highlight-current-row
    width="600px"
    @close="closeDialog"
  >
    <div>
      <el-table
        style="width: 100%"
        :data="formData"
        header-row-class-name="table-list-header"
        highlight-current-row
        border
        @current-change="handleSelectChange"
      >
        <el-table-column label="序号" type="index" />
        <el-table-column prop="name" label="筛选名称" min-width="150" />
      </el-table>
    </div>
    <div slot="footer">
      <el-button size="mini" @click="closeDialog">取消</el-button>
      <el-button size="mini" type="primary" @click="submitForm">确认</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { searchFatherData } from '@/api/shopauxPlat/screenTemplate' // 查询数据
export default {
  name: 'SearchIsSelectAll',
  props: {
    visible: {
      type: Boolean,
      default: false,
      required: true
    },
    detailDataselect: {
      type: [String, Object],
      default: ''
    },
    detailFilter: {
      type: [String, Object],
      default: ''
    }
  },
  data() {
    return {
      isEdit: true,
      submiting: false,
      hasselected: [],
      formData: {
        name: '',
        dataComeFrom: '',
        remark: '',
        state: '1'
      }

    }
  },
  computed: {
    dialogShow: {
      get() {
        return this.visible
      },
      set(val) {
        this.$emit('update:visible', val)
      }
    }
  },
  created() {
    this.initData()
    console.log(this.detailDataselect)
    console.log(this.detailFilter)
  },
  methods: {
    closeDialog() {
      this.dialogShow = false
    },
    handleSelectChange(val) {
      this.hasselected = val
    },
    // 提交表单处理
    submitForm() {
      if (!this.hasselected.name) {
        this.$message.warning('请选择一条数据!')
        return
      } else {
        this.$emit('refreshSelect', this.hasselected)
      }
    },
    initData() {
      const id = this.detailDataselect.id ? this.detailDataselect.id : null
      const filterTemplateId = this.detailFilter.id ? this.detailFilter.id : null
      searchFatherData(id, filterTemplateId).then(res => {
        if (res.success === 1) {
          this.formData = res.data
        }
      })
    }
  }
}
</script>
<style lang='scss' scoped>
.el-col el-col-11{margin-bottom: 20px;}
 .avatar-uploader .el-upload {
    border: 1px dashed #181717;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 120px;
    height: 120px;
    line-height: 120px;
    text-align: center;
  }
  .avatar {
    width: 120px;
    height: 120px;
    display: block;
  }
</style>

